"""
@author: 雫玖
@software: PyCharm
@file: TEST_002.py
@time: 2024/6/4 下午3:36
"""
# -*- coding:UTF-8 -*-
import pytest
import requests


@pytest.fixture(
    params=[{"data":{"mobilephone": "18012345678", "pwd": "12345"},
             "expect":{"status": 0, "code": "20108", "msg": "密码长度必须为6~18"}},
            {"data":{"mobilephone": "18012345678", "pwd": "1234567890123456789"},
             "expect": {"status": 0, "code": "20108","msg": "密码长度必须为6~18"}},
            {"data":{"mobilephone": "18212345678", "pwd": "123456","regname": "1234567890123456789012345678901234567890123456789012345"},
            "expect":{"status": 0, "code": "10001", "msg": "注册成功"}}
            ])
def register_data(request):  # 参数名是写死的，pytest规定好的，不能写错
    print("准备测试数据")
    # return request.param
    yield request.param  # 获取每一组的数据
    print("测试结束")


def test_register(register_data):  # login_data当作一个字典类型的变量
    r = requests.get("http://192.168.1.14:8088/futureloan/mvc/api/member/register", params=register_data['data'])
    print(f"测试注册功能，手机号为：{register_data['data']['mobilephone']}，密码为{register_data['data']['pwd']}")
    print(r.text)

    a = r.json()
    assert a['status'] == register_data['expect']['status']
    assert a['code'] == register_data['expect']['code']
    assert a['msg'] == register_data['expect']['msg']

